<template>
  <div class="login">
    <h2>用户登录</h2>
    <el-input v-model="name" placeholder="请输入用户名"></el-input>
    <el-input v-model="password" placeholder="请输入密码" type="password"></el-input>
    <el-input v-model="email" placeholder="请输入邮箱"></el-input>
    <el-button @click="Login" type="success" style="width: 120px;margin-top: 20px;">登录</el-button>
    <el-button @click="GitLogin" type="success" style="width: 120px;margin-top: 20px;">git第三方登录</el-button>
  </div>
</template>

<script>
import {gitLogin,getCode} from "../ulits/oauth";
import {ApiLogin} from "../api/index"
export default {
  data () {
    return {
      input: '',
      name:'',
      password:'',
      email:'',
    }
  },
  mounted () {
    gitLogin();
  },
  methods: {
    GitLogin(){
      getCode();
    },
    Login(){
      let name = this.name;
      let password = this.password;
      let email = this.email;
      ApiLogin({name,password,email}).then(res=>{
        if (res.data.code == 200) {
            window.location.href = 'http://localhost:8080'
            localStorage.setItem('token', res.data.token);
            this.$message({
                message: res.data.msg,
                type: 'success'
            });
        }
      })
    }
  }
}
</script>

<style lang="scss">
.login{
  width: 300px;
  height: 300px;
  margin: 100px auto;
  text-align: center;
  input{
    margin-top: 20px;
  }
}
</style>